package com.scnb.Decorator;

/**
 * 马老师没有给单独的代码示例
 * 参考的网上的例子：https://blog.csdn.net/qq_35396093/article/details/103130747
 * 设计不同种类的饮料，饮料可以添加不同的原材料，比如牛奶、糖等，并且支持动态添加新配料。
 * 每增加一种配料，饮料的价格就会增加，计算饮料的价格
 */

public class Main {
    public static void main(String[] args) {
        DrinkObject drinkObject1 = new OrangeJuice();
        drinkObject1 = new Sugar(drinkObject1);
        drinkObject1 = new Milk(drinkObject1);
        double orangeJuiceCost = drinkObject1.cost();

        System.out.println(drinkObject1.add() + "---价格: " + orangeJuiceCost);
        System.out.println("=======================");
        DrinkObject drinkObject2 = new MaiDong();
        drinkObject2 = new Sugar(drinkObject2);
        drinkObject2 = new Milk(drinkObject2);
        double maiDongCost = drinkObject2.cost();
        System.out.println(drinkObject2.add() + "---价格: " + maiDongCost);
    }
}
